<?php

namespace app\common\model;

use app\admin\model\jeek\shop\SkuGoods;
use think\Model;


class Withdraw extends Model
{



    // 表名
    protected $name = 'withdraw';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_text',
        'status_text',
        'position_text'
    ];
    

    
    public function getTypeList()
    {
        return ['1' => __('Type 1')];
    }

    public function getStatusList()
    {
        return ['1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3')];
    }

    public function getPositionList()
    {
        return ['1' => __('Position 1'), '2' => __('Position 2'),'3' => __('Position 3')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getPositionTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['position']) ? $data['position'] : '');
        $list = $this->getPositionList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function skuGoods()
    {
        return $this->belongsTo(SkuGoods::class, 'goods_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function user(){
        return $this->belongsTo(User::class, 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }



    public function copartner(){
        return $this->belongsTo(Copartner::class, 'copartner_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }




}
